import bus from '@/bus'
import {ajaxGet} from '@/util'
let getAllFilters = () => {
  let allFilters = []
  ajaxGet('/download/init').then(data => {
    let statusEnums = data.statusEnums
      for (var key in statusEnums) {
        allFilters.push({
          label: statusEnums[key],
          value: key
        })
      }
  })
  return allFilters
}
let data = {
	status: 'pass',
	totalItem: 1,
	pageSize: window.$pageSize,
	currentPage: 1,
  downloadType: null,
	columns: [{
		type: 'selection',
		align: 'left',
		width: 60
	}, {
    title: '操作时间',
    key: 'createDate',
    align: 'left',
    minWidth: 200
  }, {
		title: '操作员',
    key: 'operatorName',
    align: 'left',
    minWidth: 150
	}, {
		title: '下载类型',
		align: 'left',
		key: 'downloadTypeName',
    minWidth: 200,
    tooltip: true,
		filters: [{
      label: '优惠券领券列表',
      value: 1
    }, {
      label: '优惠券结算表明细',
      value: 2
    }, {
      label: '优惠券使用汇总',
      value: 3
    }, {
      label: '优惠券使用明细',
      value: 4
    }, {
      label: '优惠券结算',
      value: 5
    }, {
      label: '活动商品',
      value: 6
    }, {
      label: '经销商签约记录',
      value: 7
    }, {
      label: '抽奖明细',
      value: 8
    }, {
      label: '金币明细',
      value: 9
    }, {
      label: '业务员认证信息月度报告',
      value: 53
    }, {
      label: '订单列表',
      value: 48
    }, {
      label: '工厂直发统计',
      value: 50
    }, {
      label: '特价轮胎发货统计',
      value: 82
    }, {
      label: '发货统计报表',
      value: 84
    }, {
      label: '门店拜访统计',
      value: 86
    }],
    filterMultiple: false,
    filterRemote(data, key) {
      bus.$emit('changeState', { data: data, key })
    }
  }, {
		title: '状态',
    key: 'status',
    align: 'left',
    minWidth: 100,
    render: (h, params) => {
      let text
      switch (params.row.status) {
        case 'DOWN_LOADING':
          text = '进行中'
          break
        case 'SUCCESS':
          text = '成功'
          break
        case 'FAIL':
          text = '失败'
          break
        default:
          break
      }
			return h('div', text)
    }
	}, {
		title: '操作',
		align: 'right',
		minWidth: 200,
		render: (h, params) => {
      let exportBtn = h('Button', {
        style: {
          'margin-right': '5px'
        },
        props: {
          size: 'small',
          type: 'primary'
        },
        on: {
          click: () => {
            bus.$emit('downloadExcel', params.row.fileUrl)
          }
        }
      }, '导出Excel')
      let delBtn = h('Button', {
        props: {
          size: 'small',
          type: 'warning'
        },
        on: {
          click: () => {
            bus.$emit('onDelete', params.row.id)
          }
        }
      }, '删除')
      if (params.row.status == 'SUCCESS') {
        return h('div', [exportBtn, delBtn])
      } else {
        return h('div', [delBtn])
      }
		}
	}],
	data: []
}
export default data